<?php
	require_once("./config/config.php");
	
	$id = $_SESSION["id"];
	
	$db= new PDO( PDO_DSN , USER , PASSWD ) or die("Echec de connexion au serveur");
	
	$db->exec("SET NAMES 'UTF8'");
	
	$sql = "SELECT f_titre, loc_deb
	FROM locations, films
	WHERE f_id = loc_film
	AND loc_cli = :idClient
	LIMIT 2";
	
	$rq=$db->prepare($sql);
	
	$rq->bindParam(":idClient",$id);
	
	$rq->execute();
	
	$rq->bindColumn("f_titre",$film);
	$rq->bindColumn("loc_deb",$deb);
	
	$content = "";
	$rows = "";
	foreach($rq as $ligne) {
		$rows .= "<tr><td>$film</td><td>$deb</td></tr>\n";
	}

	if($rows!=""){
		$content = "<p>Derniers Films loués :</p>";
		$content .= "<table><tr><th>Film</th><th>Loué le </th></tr>\n";
		$content .= $rows;
		$content .= "</table>";
	}
	
	echo $content ;
	
?>
